<?php

namespace WoXuanWang\Video\Repositories;

use WoXuanWang\Video\Models\VideoCategory;
use zgldh\Scaffold\BaseRepository;

class VideoCategoryRepository extends BaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'name',
        'parent_id'
    ];

    /**
     * Configure the Model
     **/
    public function model()
    {
        return VideoCategory::class;
    }

    public function delete($id)
    {
        $model = $this->model();
        $model::whereParentId($id)->update(['parent_id' => null]);
        return parent::delete($id); // TODO: Change the autogenerated stub
    }
}
